﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Dictionary<QualificationLevel, IEnumerable<KeyValuePair<StudentsGroup, IEnumerable<Student>>>>>" %>
<%@ Import Namespace="Resources" %>
<%@ Import Namespace="ViewRes" %>

<%
    if (Model.Count == 0 || Model.First().Value.Count() == 0 || Model.First().Value.First().Value.Count() == 0)
    {%>
<span class='mediumBoldText'>
    <%:AdministratorsStrings.NoStudents%></span>
<%
    } %>
<%
    else
    {%>
    <%
        string defaultAction = ViewData["DefaultAction"] == null ? null : ViewData["DefaultAction"].ToString();
        string confirmationString = null;

        string submitButtonValue = null;
        switch (defaultAction)
        {
            case "Delete":
                submitButtonValue = DiplomaResources.Delete;
                confirmationString = DiplomaResources.DoYouConfirmDeletion;
                break;
            case "Restore":
                submitButtonValue = DiplomaResources.Restore;
                confirmationString = DiplomaResources.DoYouConfirmRestoring;
                break;
            default:
                break;
        }
%>

    <%
        using (
            Html.BeginRouteForm("Default", new {controller = "Students", action = defaultAction}, FormMethod.Post,
                                new {onSuccess = "loadActiveEntries(); "}))
        {%>
        <%
            foreach (var level in Model)
            {%>
          <div class="mediumBoldText"><%:level.Key.ToString()%></div> 
          <ol style="list-style: none outside none;">
            <%
                foreach (var group in level.Value)
                {%>
                <div class="mediumBoldText"><%:group.Key.Name%></div>
                 <ol style="list-style: none outside none;">
                        <%
                    foreach (Student student in group.Value)
                    {%>
                            <%
                        Html.RenderPartial("~/Views/Students/ViewStudentControl.ascx", student);%>
                        <%
                    }%>
                 </ol>
              <%
                }%>
              </ol>
          <%
            }%>
          
          <hr />
         <input type="submit" value="<%=submitButtonValue%>" onclick=" return deleteEntity('<%=confirmationString%> ', studentDeleted)" />

        <%
        }%>
<%
    }%>